package com.zjpavt.taiyuan.service.flowManager;

import com.zjpavt.taiyuan.utils.SHA256Util;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Author caozhi
 * @Date 2020/1/13
 * @Description 移动平台公共请求参数
 * @Param
 * @Return
 */
@Component
@ConfigurationProperties(prefix = "mobile")
public class CommonRequest {
//    @Value("${mobile.appid}")
    private static String appid;

    private static String transid;

    private static String ebid;

    private static String password;

    private static String token;

    static {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
        String format = simpleDateFormat.format(new Date());
        transid = appid + format + 00000001;
        String tokenString = appid + password + transid;
        token = SHA256Util.getSHA256String(tokenString);
    }


    public static String getAppid() {
        return appid;
    }

    @Value("${mobile.appid}")
    public void setAppid(String appid) {
        this.appid = appid;
    }

    public static String getTransid() {
        return transid;
    }

    public void setTransid(String transid) {
        this.transid = transid;
    }

    public static String getEbid() {
        return ebid;
    }

    @Value("${mobile.appid}")
    public void setEbid(String ebid) {
        this.ebid = ebid;
    }

    public static String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public static String getPassword() {
        return password;
    }

    @Value("${mobile.password}")
    public void setPassword(String password) {
        CommonRequest.password = password;
    }
}
